{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.30 Nozzle Sizing Calculations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Objective: Size a long-radius venturi nozzle flow meter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A system is designed with a flow rate of 225 gpm of water at 60 F flowing through 6\" schedule 40 pipe. A long-radius nozzle flow has been requested. A measured head loss of 4 feet is the design measurement, with 1D upstream and 1/2D downstream taps.\n",
    "\n",
    "Find the required diameter of the nozzle."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "\n",
    "mu = 1.1*u.cP\n",
    "rho = 62.364*u.lb/u.ft**3\n",
    "\n",
    "NPS, Di, Do, t = nearest_pipe(NPS=6, schedule='40')\n",
    "A = 0.25*pi*Di*Di\n",
    "\n",
    "dP = 4*u.feet_H2O\n",
    "\n",
    "P1 = 10*u.bar # assumed, not very important\n",
    "P2 = P1 - dP\n",
    "k = 1.3 # not important\n",
    "\n",
    "Q = 225*u.gal/u.min\n",
    "m = Q*rho"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nozzle diameter found to be 2.405956564895703 inch.\n"
     ]
    }
   ],
   "source": [
    "Do = differential_pressure_meter_solver(D=Di, rho=rho, mu=mu, k=k, P1=P1, P2=P2, \n",
    "                                   m=m, meter_type='long radius nozzle', \n",
    "                                   taps='D')\n",
    "print('Nozzle diameter found to be %s.' %(Do.to(u.inch)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The solution given in Crane is 2.40 inches after two iterations and has an error of 0.4 gpm, whereas the answer above has almost zero theoretical error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.31 NPRD Calculations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Non-recoverable pressure drop (NRPD) is the permanent pressure drop associated with the flow through the measurement device.\n",
    "Find the NPRD for example 7.30."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "0.9839001432452787 dimensionless"
      ],
      "text/latex": [
       "$0.9839001432452787\\ dimensionless$"
      ],
      "text/plain": [
       "0.9839001432452787 <Unit('dimensionless')>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C, epsilon = differential_pressure_meter_C_epsilon(D=Di, D2=Do, m=m, P1=P1, P2=P2, rho=rho, mu=mu, k=k,\n",
    "                                          meter_type='long radius nozzle')\n",
    "C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "1.2691031722533113 pound_force_per_square_inch"
      ],
      "text/latex": [
       "$1.2691031722533113\\ \\mathrm{pound\\_force\\_per\\_square\\_inch}$"
      ],
      "text/plain": [
       "1.2691031722533113 <Unit('pound_force_per_square_inch')>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dP = differential_pressure_meter_dP(D=Di, D2=Do, P1=P1, P2=P2, C=C, \n",
    "                                   meter_type='long radius nozzle')\n",
    "\n",
    "dP.to(u.psi)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The solution given in Crane is 1.272 psi."
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
